package com.chencong.transform;

import com.chencong.env.FlinkTableEnv;
import org.apache.flink.api.common.functions.FilterFunction;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

/**
 * @Author chencong
 * @Description 过滤
 * @Date 8:15 下午 2021/8/17
 * @Param
 **/
public class Filter {
    public static void main(String[] args) throws Exception {
        StreamExecutionEnvironment streamTableEnvironment = FlinkTableEnv.getStreamTableEnvironment();
        streamTableEnvironment.setParallelism(1);

        DataStreamSource<Integer> DS = streamTableEnvironment.fromElements(1, 2, 3, 4, 5);

        // TODO Filter

        DS.filter(new FilterFunction<Integer>() {
            @Override
            public boolean filter(Integer value) throws Exception {
                return value % 2 == 0;
            }
        }).print();

        streamTableEnvironment.execute();

    }
}
